<template>
	<view class="content">
		<mescroll-body ref="mescrollRef" :bottombar="false" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="" >
				<u-cell-group>
					<block v-for="(item,index) in noticList" :key="index">
						<u-cell-item :title="item.title" :arrow="true" :index="index" @click="itemClick"></u-cell-item>
					</block>
				</u-cell-group>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import { BaseCenterApi } from '@/api/serves.js'
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				noticList: []
			}
		},
		onLoad() {

		},
		methods: {
			// 上拉加载
			upCallback(page) {
				BaseCenterApi.getNoticList().then(res => {
				  console.log('获取公告', res);
				  if(res.code == 1){
				  	let result = res.data
				  	if(page.num == 1) this.noticList = []; //如果是第一页需手动制空列表
				  	this.noticList = this.noticList.concat(result); //追加新数据
				  	this.mescroll.endByPage(result.length, res.totalpage)
				  }else {
				  	this.$toast(res.msg)
				  	this.mescroll.endErr()
				  }
				})
			},
			itemClick(index) {
				uni.navigateTo({
					url: '/pages/notic/noticDetail/noticDetail?id=' + this.noticList[index].id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
